<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 市场动态模块
 * 
 * @author  : $Author: spike $
 * @date    : $Date: 2014-03-03 09:31:20 +0800 (一, 2014-03-03) $
 * @version : $Id: trend.php 39 2014-03-03 01:31:20Z spike $
 * @rev     : $Revision: 39 $
 */
class Trend extends MY_Controller 
{
	public function __construct()
    {
        parent::__construct();
    }

    public function search()
    {
    	$params = $this->input->get();

        $this->load->model('Trend_model');
        $list = $this->Trend_model->browse_trend($params, $params['page'], 12);
        
        $this->load->library('pagination');
        $config['total_rows'] = $list['total'];
        $config['per_page']   = $list['size'];

        $this->pagination->initialize($config); 
        $pagination = $this->pagination->create_links();

    	$data = array(
            'pagination' => $pagination,
            'default'    => $params ? $params : array(),
            'total'      => $total,
            'list'       => $list,
            'current_url'=> DOMAIN.'trend/search',
        );

        $this->load->view('home/header.tpl', $data);
        $this->load->view('trend/search.tpl');
        $this->load->view('home/footer.tpl');
    }

    public function view($trend_id = NULL)
    {
        $this->load->model('Trend_model');
        if( ! $trend = $this->Trend_model->get_trend($trend_id, TRUE))
        {
            show_error("无法找到市场动态。");
        }

        $data  = array(
            'trend'   => $trend,
        );

        $this->load->view('home/header.tpl', $data);
        $this->load->view('trend/view.tpl');
        $this->load->view('home/footer.tpl');
    }
}